home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6987 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: pacifica.access.ch!usenet
  2. From: tombeck@usemail.com (Thomas Beck)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Please please help a newbie!!
  5. Date: 16 Feb 1996 23:36:18 GMT
  6. Organization: Internet Access AG, Zuerich, Switzerland
  7. Message-ID: <4g34di$mg0@pacifica.access.ch>
  8. References: <4fth5k$43v@pacifica.access.ch>
  9. NNTP-Posting-Host: gatezh2-16.access.ch
  10. X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
  11.  
  12. In message <4g01js$h6q@sun001.spd.dsccc.com> - jmccarty@spd.dsccc.com (Mike McC
  13. arty) writes:
  14.  
  15. >)----------- example 1: -------------
  16. >)int i;
  17. >)int & a=i;
  18. >     ^ If you are trying to declare a pointer to
  19. >       an integer, and set it to point to i, then you need this line:
  20. >
  21. >    int    *a = &i;
  22.  
  23. I have to apologize for posting to the wrong group. I've realized that my 
  24. problems are C++ specific. If I had thought about it, I should have known.
  25. int & a=i means that a is a reference of i, so whenever you change a, i gets 
  26. the same value.
  27.  
  28. >)----------- example 2: -------------
  29. >)struct abc {
  30. >)  int i;
  31. >)  char a;
  32. >)  void f1() {
  33. >        ^ If you are trying to declare a pointer
  34. >      to a function returning void, then you need
  35. >        void    *f1();
  36. >      no "{}" are needed.
  37.  
  38. It just means a function within a class. Also this is possible in C++.
  39.  
  40. Now why did my C++ compiler not compile it? Because I had named the file 
  41. test.c instead of test.cpp. Gee, I never thought a program could rely that 
  42. much on an extension! I mean, if I tell my computer "scc test.c", and scc is 
  43. a C++ compiler, shouldn't it just do it? Oh well... :-)
  44.  
  45. Thomas Beck, tombeck@usemail.com
  46.  
  47. =================================================================
  48. Summer's day, as she passed away. Birds were singing in the
  49. summer sky; then came the rain, and once again, a tear fell
  50. from her mother's eye...
  51. =================================================================
  52.  
  53.